<?php

/**
 * action form.
 *
 * @package    gesp
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class tacheChargeForm extends BasetacheForm {
	public function configure() {
		$this->widgetSchema->setNameFormat('tac_charge[%s]');

		unset($this['tac_prj_id']);
		unset($this['tac_parent_id']);
		unset($this['tac_cat_id']);
		unset($this['tac_libelle']);
		unset($this['tac_description']);
		unset($this['tac_urgence']);
		unset($this['tac_date_debut']);
		unset($this['tac_date_echeance']);
		unset($this['tac_date_fin']);
		unset($this['tac_charge_estimee']);
		unset($this->widgetSchema['tac_charge_consommee']);
		unset($this['tac_charge_restante']);
		unset($this['tac_etat']);
		unset($this['tac_termine']);
		unset($this['created_at']);
		unset($this['updated_at']);
		
		$this->setWidget('nouvelle_charge_consommee', new sfWidgetFormInput(array(), array('value' => '0')));
		$this->setValidator('nouvelle_charge_consommee', new sfValidatorNumber(array('required' => false)));

		$charge_restante = $this->getObject()->getTacChargeRestante();
		$this->setWidget('nouvelle_charge_restante', new sfWidgetFormInput(array(), array('value' => $charge_restante)));
		$this->setValidator('nouvelle_charge_restante', new sfValidatorNumber(array('required' => false)));
		
		$i = 0;
		$this->setWidget('etat_suivant', new sfWidgetFormInputHidden(array(), array('value' => -1)));
		$this->setValidator('etat_suivant', new sfValidatorInteger(array('required' => true)));

		foreach ($this->getObject()->getEtatsSuivant() as $k => $v) {
			$etat_list[$k] = $v;
			$this->setWidget(
				"etat_suivant_$i", 
				new sfWidgetFormInput(
					array('type' => 'button'),
					array('onClick' => "setEtat($k)", 'value' => $v)
				)
			);
			$i++;
		}
		
/*
		$etat = $this->getObject()->getEtat();
		$etat_list = array($etat->getLibCode() => ucfirst($etat->getLibLibelle()));
		foreach ($this->getObject()->getEtatsSuivant() as $k => $v) {
			$etat_list[$k] = $v;
		}
		$this->setWidget(
			'etat_suivant', 
			new sfWidgetFormChoice(array(
				'choices' => $etat_list,
				'default' => $etat->getLibCode(),
				'expanded' => true,
				'multiple' => false,
			))
		);
		$this->setValidator('etat_suivant', new sfValidatorChoice(array('choices' => array_keys($etat_list))));
*/
	}
}
